<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  mz_seccontent.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.20  $
  '  $Date:   08 Oct 1998 16:05:14  $
  '  $Author:   rurman  $
  '  $Workfile:   mz_seccontent.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="islogon.asp" -->
<%
DebugFlag = 0
IEBrowser = InStr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE")

ObjType = CInt(Request.QueryString("Type"))
Ident  = Request.QueryString("Ident")
Update = Request.QueryString("Update")
Status = Request.QueryString("Status")

'Panagon IDM Web application uses the Session variable LibraryLogonID to keep track of
'whether the user has logged on.
'Please see logoncall.asp to see how the Session variable LibraryLogonID is set.
LibraryLogonID = Session("LibraryLogonID")
Username = Session("Username")
set LibraryObj = Server.CreateObject("IDMObjects.Library")
LibraryObj.LogonID = LibraryLogonID

On Error Resume Next
set FObj = LibraryObj.GetObject(ObjType, Ident)
if Len(Err.Description) then
    Response.Expires = 0
    Response.Status = "404 Not Found"
    Response.ContentType = "text/plain"
    Response.Write "Object not found: "
    Response.Write Err.Description
    Response.End
end if
%>

<!-- #include file="jscriptfix.asp" -->

<%
Function ConvertPermissionLevelLabel(ID)
    select case ID
        case Application("idmObjTypeUser")
            s = "User"
        case Application("idmObjTypeGroup")
            s = "Group"
    end select
    ConvertPermissionLevelLabel = s
end Function

Function ConvertPermissionLabel(ID)
    select case ID
        case Application("idmDSAccessNone")
            s = "None"
        case Application("idmDSAccessViewer")
            s = "Viewer"
        case Application("idmDSAccessAuthor")
            s = "Author"
        case Application("idmDSAccessOwner")
            s = "Owner"
        case Application("idmDSAccessAdmin")
            s = "Admin"
        case Else
            s = "Unknown"
    end select
    ConvertPermissionLabel = s
End Function

%>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>Property View</title>
</head>

<body bgcolor="#FFFFFF">

<table border="0" cellpadding="4" cellspacing="0">
    <tr>
        <td nowrap><% if ObjType = Application("idmObjTypeDocument") then %><img src="images/ldoc.gif" width="34" height="39"><% else %><img
        src="images/lfolder.gif" width="38" height="39"><% end if %><font
        size="3"><strong><%= Ident %> ("<%=Server.HTMLEncode(FObj.Label) %>") :  Modify <% if ObjType = Application("idmObjTypeDocument") then %>Document <% else %>Folder <%end if%>Security </strong> </font>
        <% 
        if Update = "1" then
            if Status = "1" then %>
                <font color="#0000FF" size="4"><strong><em>
                ( Security updated successfully. )
            <% elseif Status = "-1" then %>
                <font color="#AA0000" size="4"><strong><em>
                ( Security update failed ! )
        <%  end if
        end if %>
        </em></strong></font>
        </td>
    </tr>
</table>

<%
set Users = LibraryObj.Users
set Groups = LibraryObj.Groups


set Permissions = FObj.Permissions

IsVirtual = false
if ObjType = Application("idmObjTypeFolder") then

    if FObj.GetState(5) then ' 5=idmFolderIsReplica
            IsVirtual = true
    end if

end if
%>

<form name="property" action="mz_secupdate.asp" method="POST">
    <input type="hidden" name="Type" value="<%= ObjType %>">
    <input type="hidden" name="Ident" value="<%= Ident %>">
    <input type="hidden" name="Modify" value="1">
<H3> Remove Users and Groups </H3>
<table border="1" width="80%" cellpadding="0" cellspacing="1">
    <tr>
                
        <td align="center" width="25%" bgcolor="#EECCFF"><font size="3"><strong>Name</strong></font></td>
        <td align="center" width="25%" bgcolor="#EECCFF"><font size="3"><strong>Type</strong></font></td>
        <td align="center" width="25%" bgcolor="#EECCFF"><font size="3"><strong>Access</strong></font></td>
        <td align="center" width="25%" bgcolor="#EECCFF"><font size="3"><strong>Delete</strong></font></td>
                
    </tr>

    <%
    ' enumerate through the permissions list and display in a table
    ' name / access and checbox to allow delete of this value
    for i=1 to Permissions.Count
        set Permission = Permissions.Item(i)
        GranteeName = Permission.GranteeName
        GranteeAccess = ConvertPermissionLevelLabel(Permission.GranteeType)
        
     %>
    <tr>
    <td valign=bottom><em><%=GranteeName%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td valign=bottom><em><%=GranteeAccess%>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td valign=bottom><em><%= ConvertPermissionLabel(Permission.Access) %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td align=center>
        <% 
        ' don't allow to delete yourself from the access list
        if UCase(Username) <> UCase(GranteeName) then %>
        <input type="checkbox" name="DELETE" value="<%= i %>"> <% end if %></td>
    <!-- <td align=center><input type="checkbox" name="DELETE_<%=GranteeAccess%>_<%= GranteeName %>" value="<%= i %>"></td> -->
    </tr>
    <% next %>
</table>

<br>
<H3> Add Users and Groups </H3>
<%
if IEBrowser then %>
<table frame="box" rules="groups" border="1" width="80%" cellpadding="0" cellspacing="1">
<% else %>
<table frame="box" rules="groups" border="0" width="80%" cellpadding="0" cellspacing="1">
<% end if %>
<COLGROUP>
    <COL SPAN="2" ALIGN="left">
<COLGROUP>
    <COL SPAN="2" ALIGN="left">
<THEAD>
    <tr>
                
        <td align="left" width="34%" bgcolor="#EECCFF"><font size="3"><strong>Users</strong></font></td>
        <td align="left" width="16%" bgcolor="#EECCFF"><font size="3"><strong>Access</strong></font></td>
        <td align="left" width="34%" bgcolor="#EECCFF"><font size="3"><strong>Groups</strong></font></td>
        <td align="left" width="16%" bgcolor="#EECCFF"><font size="3"><strong>Access</strong></font></td>
                
    </tr>

<TBODY>
    <%
    ' allow to add 4 more users and groups to the access list 
    strDefAccess = CStr(Application("idmDSAccessNone"))
    for k=1 to 4 %>
    <tr>
    <td valign=bottom>
        <select name="ADD_USER_<%=k%>" size="1">
            <option>
            <% 
            ' enumerate through the users list and provide a selection list
            for each user in Users
                Username = user.Name %>
            <option value="<%= Username %>" > <%= Username %>&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <% next %>
        </select>
    </td>

    <td valign=bottom>
        <select name="ACCESS_USER_<%=k%>" size="1" >
            <option>
            <option value="<%=Application("idmDSAccessNone")%>" >None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmDSAccessViewer")%>" >Viewer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmDSAccessAuthor")%>" >Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmDSAccessOwner")%>" >Owner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
        </select>
    </td>

    <td valign=bottom>
        <select name="ADD_GROUP_<%=k%>" size="1">
            <option>
            <% 
            ' enumerate through the groups list and provide a selection list
            for each group in Groups
                Groupname = group.Name %>
            <option value="<%= Groupname %>" > <%= Groupname %>&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <% next %>
        </select>
    </td>

    <td valign=bottom>
        <select name="ACCESS_GROUP_<%=k%>" size="1">
            <option>
            <option value="<%=Application("idmDSAccessNone")%>" >None&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmDSAccessViewer")%>" >Viewer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmDSAccessAuthor")%>" >Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
            <option value="<%=Application("idmDSAccessOwner")%>" >Owner&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>
        </select>
    </td>
    </tr>
    <% next %>
</table>
<% 
if IEBrowser then %>
<br>
<% else %>
<hr>
<% end if %>
<table border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td width="30" valign=bottom align=right></td>
    <td>
    <% if not IsVirtual then %>
    <a href="javascript:Update()"><img alt="Update Security" src="images/update.gif" align=bottom border=0 width=41 height=41></a><em><strong>Update</strong></em>
        <%if ObjType = Application("idmObjTypeDocument") then %>
    <a target="_top" href="property.asp?Ident=<%=Ident%>&Type=<%=ObjType%>&Modify=1"><img alt="Modify Properties" src="images/modify.gif" align=bottom border=0 width=47 height=43></a><em><strong>Modify properties</strong></em>
        <% end if %>
    <% end if %>
    </td>
    </tr>
</table>

<input type="hidden" name="UpdateFlag" value="1">
</form>


<SCRIPT LANGUAGE="JavaScript">
<!--
// the Submit button calls the mz_secupdate.asp which performs the update of the access list
function Update()
{
    document.property.UpdateFlag.value = "1";
    document.property.submit();
}
//-->
</SCRIPT>

&nbsp;<br>
</body>
</html>
